package frankie;

import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.context.request.AsyncWebRequestInterceptor;
import org.springframework.web.context.request.WebRequest;
import org.springframework.web.context.request.WebRequestInterceptor;
import org.springframework.web.servlet.*;
import org.springframework.web.servlet.handler.*;
import org.springframework.web.servlet.mvc.Controller;
import org.springframework.web.servlet.mvc.HttpRequestHandlerAdapter;
import org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter;
import org.springframework.web.servlet.mvc.annotation.ResponseStatusExceptionResolver;
import org.springframework.web.servlet.mvc.method.annotation.ExceptionHandlerExceptionResolver;
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter;
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping;
import org.springframework.web.servlet.mvc.support.DefaultHandlerExceptionResolver;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Locale;

/**
 * Created by whyang on 2017/05/11.
 */

public class tryMVC001 {


    Controller ctrl = new Controller() {
        @Override
        public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception {
            return null;
        }
    };


    HttpServlet httpSvlt = new HttpServlet() {
        @Override
        protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
            super.doGet(req, resp);
        }
    };


    FrameworkServlet frwkSvlt = new FrameworkServlet() {
        @Override
        protected void doService(HttpServletRequest request, HttpServletResponse response) throws Exception {

        }
    };


    DispatcherServlet dpchSvlt = new DispatcherServlet();


    HandlerAdapter hdlrAdpt = new HandlerAdapter() {
        @Override
        public boolean supports(Object handler) {
            return false;
        }

        @Override
        public ModelAndView handle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
            return null;
        }

        @Override
        public long getLastModified(HttpServletRequest request, Object handler) {
            return 0;
        }
    };


    HandlerMapping hdlrMpp = new HandlerMapping() {
        @Override
        public HandlerExecutionChain getHandler(HttpServletRequest request) throws Exception {
            return null;
        }
    };


//    SimpleControllerHandlerAdapter


    ViewResolver vwRslr = new ViewResolver() {
        @Override
        public View resolveViewName(String viewName, Locale locale) throws Exception {
            return null;
        }
    };


//    HandlerException hdlrExcpt;
    HandlerExecutionChain hdlrExcptChain;

    ExceptionHandler excptHndlr;

    //  居然还有一个ExceptionResolver ？！
    //  HandlerExceptionResolver;
    DefaultHandlerExceptionResolver defHdlrExptRslvr = new DefaultHandlerExceptionResolver();
    SimpleMappingExceptionResolver splMppExptRslvr = new SimpleMappingExceptionResolver();
    ExceptionHandlerExceptionResolver exptHdlrExptRslvr = new ExceptionHandlerExceptionResolver();
    ResponseStatusExceptionResolver rspStusExptRslvr = new ResponseStatusExceptionResolver();


    SimpleServletHandlerAdapter smplSvltAdptr = new SimpleServletHandlerAdapter();
    SimpleControllerHandlerAdapter smplCtrlAdptr = new SimpleControllerHandlerAdapter();

//    AnnotationMethodHandlerAdapter;

//    WebRequestInterceptor;
//    HandlerInterceptor;


    RestController restCtlr;

    HandlerExecutionChain hdlrExctChain = new HandlerExecutionChain(restCtlr);


    /********************HandlerIntercept & HandlerInterceptAdapter*******************/

    HandlerInterceptor hndlrIncptr = new HandlerInterceptor() {
        @Override
        public int hashCode() {
            return super.hashCode();
        }
    };

    WebRequestInterceptor webReqIncptr = new AsyncWebRequestInterceptor() {
        @Override
        public void afterConcurrentHandlingStarted(WebRequest request) {

        }

        @Override
        public void preHandle(WebRequest request) throws Exception {

        }

        @Override
        public void postHandle(WebRequest request, ModelMap model) throws Exception {

        }

        @Override
        public void afterCompletion(WebRequest request, Exception ex) throws Exception {

        }
    };

    HandlerInterceptorAdapter hndlIntcptAdptr = new HandlerInterceptorAdapter() {
        @Override
        public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
            return super.preHandle(request, response, handler);
        }

        @Override
        public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {

        }

        @Override
        public void afterCompletion(
                HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex)
                throws Exception {
        }

    };

    WebRequestHandlerInterceptorAdapter webReqHndlrIncptAdptr = new WebRequestHandlerInterceptorAdapter(webReqIncptr);


    DispatcherServlet dispSvlt;

//    MultiActionController mactlr;
//    ControllerClassNameHandlerMapping controllerClassNameHandlerMapping;

    RequestMappingHandlerMapping reqMpHdlMp;
    RequestMappingHandlerAdapter reqMpHdlAdpt;

    BeanNameUrlHandlerMapping beanNameUrlHdlMp;

    HttpRequestHandlerAdapter httpReqHdlAdpt;



    /*org.springframework.web.servlet.mvc.multiaction;
    MultiActionController;*/


}
